<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h3>new一个函数实例化的过程</h3>
    <script>
        let newMethod = function(Parent, ...rest) {
            let child = Object.create(Parent.prototype);
            // Object.create() 实质
            // Object.create =  function (Parent) {
            //     var F = function () {};
            //     F.__proto__ = Parent.prototype;
            //     return new F();
            // };
            let result = Parent.apply(child, rest);
            return typeof result === 'object'? result : child;
        }
    </script>
</body>
</html>